import React from "react";
import { Router, Route, hashHistory, Redirect, IndexRoute, IndexRedirect } from 'react-router';

import main from '@/components/main/index/jsx/main.jsx';
import HOME from '@/components/main/home';
import Login from '@/components/main/login';
import NotFound from '@/components/main/not-found';

const isOnline = process.env.NODE_ENV == "production";
const IndexEnter = () => {
    if (isOnline) {
        location.replace("/")
        return null;
    }

    return "index"
}



//<Route path="demo" getComponent={demo} />

class Routers extends React.Component {
    render() {
        return (
            <Router history={hashHistory} >
                <Route path="/" component={main} >
                  <IndexRoute onEnter={IndexEnter} />
                    <Route path="home" component={HOME} />
                    <Route path="login" component={Login} />
                    {/* <Route path="demo" getComponent={demo} /> */}
                    <Route path="404" component={NotFound} />
                    <Redirect from="*" to="/404" />
                </Route>
            </Router>
        )
    }
}

export default Routers;
